import { ref, watch } from 'vue'
export default function () {
  let goodObj = ref({ a: 1, b: 2, c: 3, d: 4 })
  let changeGoodObj = () => {
    goodObj.value = { a: 2, b: 2, c: 2, d: 2 }
  }
  let changePartGoodObj = () => {
    goodObj.value.a += 1
  }
  watch(
    goodObj,
    (newVal, oldVal) => {
      console.log('goodObj', newVal, oldVal)
    },
    {
      deep:true, //深度监听才可以监听到属性变化
      // immediate:true 
    }
  )
  return { goodObj, changeGoodObj,changePartGoodObj }
}
